package cn.school.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.school.entity.Grade;
import cn.school.entity.Student;
import cn.school.service.Service;
import cn.school.service.Service2;

/**
 * Servlet implementation class UpdateStudentServlet2
 */
@WebServlet("/UpdateStudentServlet2")
public class UpdateStudentServlet2 extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public UpdateStudentServlet2() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		// response.getWriter().append("Served at: ").append(request.getContextPath());
		response.setContentType("text/html;charset=utf-8");
		int stuno = Integer.parseInt(request.getParameter("stuno"));

		Service service = new Service();
		Student stu = service.getOne(stuno);
		Service2 s2 = new Service2();
		List<Grade> list = s2.findALL();
		request.setAttribute("list", list);
		request.setAttribute("stu", stu);
		request.getRequestDispatcher("updateStudo.jsp").forward(request, response);

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
